---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\fsu2010\formateur\ajps\submission2\replication\analysis\IIAtest_rand.log
  log type:  text
 opened on:  11 Nov 2010, 15:23:18

. #delimit ;
delimiter now ;
. set more off;

. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:  IIAtest_rand.do                                     *;
. *       Date:       November 11, 2010                                   *;
. *       Author:     MRG                                                 *;
. *       Purpose:    Do Hausman tests on europe.dta                      *;
. *       Input File:     europe.dta                                      *;
. *       Output File:    IIAtest.log                                     *;
. *       Data Output:    none                                            *;
. *       Previous file:  europe.dta                                      *;
. *       Machine:        Matt's desktop                                  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. use "C:\fsu2010\formateur\ajps\submission2\replication\analysis\europe.dta", clear;

. *     ****************************************************************  *;
. *       IIA test dropping one party at a time.                          *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Drop missing observations to ensure Hausman tests are valid     *;
. *     ****************************************************************  *;
. drop if previousPM_conflict==.;
(123 observations deleted)

. drop if previousPM_gain==.;
(166 observations deleted)

.  *     ****************************************************************  *;
. *       Generate counter variable for formation opportunity             *;
. *     ****************************************************************  *;
. egen cabcount = group(cabinetcode);

. xtset cabinetcode partyID;
       panel variable:  cabinetcode (unbalanced)
        time variable:  partyID, 1 to 28, but with gaps
                delta:  1 unit

. xtdescribe;

cabinetcode:  104, 105, ..., 2809                            n =        335
 partyID:  1, 2, ..., 28                                     T =         28
           Delta(partyID) = 1 unit
           Span(partyID)  = 28 periods
           (cabinetcode*partyID uniquely identifies each observation)

Distribution of T_i:   min      5%     25%       50%       75%     95%     max
                         1       3       5         6         8      11      18

     Freq.  Percent    Cum. |  Pattern
 ---------------------------+------------------------------
       17      5.07    5.07 |  11.1.1.1....................
       11      3.28    8.36 |  ..1......1.1..1.............
       10      2.99   11.34 |  ....111.....................
        8      2.39   13.73 |  1....111...11...............
        8      2.39   16.12 |  1.1.1.1.11..................
        7      2.09   18.21 |  ..111.......................
        7      2.09   20.30 |  .11111......................
        7      2.09   22.39 |  1.1...1.1.11....1.1...1.....
        7      2.09   24.48 |  1.1.111111..................
      253     75.52  100.00 | (other patterns)
 ---------------------------+------------------------------
      335    100.00         |  XXXXXXXXXXXXXXXXXXXXXXXXXXXX

. sum;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
 cabinetcode |      2123    1065.512    703.5159        104       2809
     partyID |      2123    8.152614    5.713245          1         28
 countrycode |      2123    10.48422    7.075073          1         28
     country |         0
party_seat~e |      2123    15.21923    13.69418   .1574803         50
-------------+--------------------------------------------------------
      choice |      2123    .1540273      .36106          0          1
  previousPM |      2123    .1516722    .3587873          0          1
medianparty1 |      2039    .1510544    .3581898          0          1
presidentp~y |      2123    .0701837    .2555165          0          1
largestparty |      2123    .1559114    .3628568          0          1
-------------+--------------------------------------------------------
      altnum |      2123    4.162506    2.592578          1         18
previousPM~n |      2123   -.5026256    6.412367  -87.87234    90.9091
previousPM~1 |      2123   -.2855845    2.577713   -46.2486   11.17319
previous_c~n |      2123     .679547    16.39297  -78.33332   376.6667
previous_c~1 |      2123   -.0765946    5.505644        -54   58.33333
-------------+--------------------------------------------------------
president_~e |      2123    .0414508    .1993774          0          1
president~ct |      2123    .0456901    .2088613          0          1
previousP~ct |      2123    .0621762    .2415321          0          1
        east |      2123    .1573245    .3641923          0          1
largestp~ast |      2123    .0254357    .1574815          0          1
-------------+--------------------------------------------------------
party_se~ast |      2123    2.325915    7.105837          0         50
medianpa~ast |      2039     .015694    .1243191          0          1
presi~y_east |      2123    .0117758    .1079009          0          1
presi~e_east |      2123    .0117758    .1079009          0          1
presi~t_east |      2123    .0061234    .0780306          0          1
-------------+--------------------------------------------------------
previ~M_east |      2123    .0226095    .1486901          0          1
previousPM.. |      2123   -.1112965    1.843632   -46.2486   4.404144
~M_gain_east |      2123   -.2207147    4.031294  -87.87234         30
previous_c.. |      2123   -.0112346    1.274609  -36.66666   18.91305
~t_gain_east |      2123    .0008447    2.580505  -67.34694   40.47619
-------------+--------------------------------------------------------
previ~t_east |      2123    .0113048     .105746          0          1
        west |      2123    .8426755    .3641923          0          1
largestp~est |      2123    .1304757    .3369055          0          1
party_se~est |      2123    12.89331    14.03721          0         50
medianpa~est |      2039    .1353605    .3421921          0          1
-------------+--------------------------------------------------------
presi~y_west |      2123    .0584079    .2345684          0          1
presi~e_west |      2123     .029675    .1697291          0          1
presi~t_west |      2123    .0395667    .1949847          0          1
previ~M_west |      2123    .1290626    .3353483          0          1
previousPM.. |      2123   -.1742879    1.812302   -37.2617   11.17319
-------------+--------------------------------------------------------
~M_gain_west |      2123    -.281911    4.999162  -79.04411    90.9091
previous_c.. |      2123     -.06536    5.356207        -54   58.33333
~t_gain_west |      2123    .6787023    16.18863  -78.33332   376.6667
previ~t_west |      2123    .0508714    .2197869          0          1
    cabcount |      2123    167.2077    94.96788          1        335

.  *     ****************************************************************  *;
. *       Model 6 using clogit.                                           *;
. *     ****************************************************************  *;
. clogit choice largestparty party_seatshare medianparty1 presidentparty previousPM president_investiture 
>         president_direct previousPM_conflict previousPM_gain1 previous_cabinet_gain1
>         largestparty_east party_seatshare_east medianparty1_east presidentparty_east previousPM_east 
>         previousPM_conflict_east previousPM_gain1_east previous_cabinet_gain1_east,  
>         group(cabinetcode);

Iteration 0:   log likelihood = -259.26598  
Iteration 1:   log likelihood = -253.62196  
Iteration 2:   log likelihood = -229.48762  
Iteration 3:   log likelihood = -229.12527  
Iteration 4:   log likelihood = -229.12428  
Iteration 5:   log likelihood = -229.12428  

Conditional (fixed-effects) logistic regression   Number of obs   =       2039
                                                  LR chi2(18)     =     676.86
                                                  Prob > chi2     =     0.0000
Log likelihood = -229.12428                       Pseudo R2       =     0.5963

------------------------------------------------------------------------------
      choice |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
largestparty |    .513825   .2530113     2.03   0.042     .0179321    1.009718
party_seat~e |   .0920104   .0131823     6.98   0.000     .0661737    .1178472
medianparty1 |   .8034385   .1912084     4.20   0.000     .4286769      1.1782
presidentp~y |   2.344388   .8603292     2.72   0.006     .6581738    4.030602
  previousPM |   .9622781   .2453506     3.92   0.000     .4813998    1.443156
president_~e |  -1.812223   .7187738    -2.52   0.012    -3.220994   -.4034521
president~ct |  -1.944626   .7822903    -2.49   0.013    -3.477887    -.411365
previousP~ct |  -.7414724   .3545053    -2.09   0.036     -1.43629   -.0466549
previousPM~1 |   .1610095   .0424693     3.79   0.000     .0777713    .2442477
previous_c~1 |   .0060267   .0110097     0.55   0.584    -.0155519    .0276052
largestp~ast |  -.5553664   .8193583    -0.68   0.498    -2.161279    1.050546
party_se~ast |   .1350519    .070639     1.91   0.056    -.0033981    .2735019
medianpa~ast |  -1.397295   .7507114    -1.86   0.063    -2.868663     .074072
presi~y_east |   .5460676   .9797752     0.56   0.577    -1.374256    2.466392
previ~M_east |  -.5906285   .8963622    -0.66   0.510    -2.347466    1.166209
previ~t_east |   .1976854   1.204658     0.16   0.870    -2.163401    2.558772
previousPM.. |  -.0502768   .1498107    -0.34   0.737    -.3439004    .2433469
previous_c.. |   .0112033   .0713777     0.16   0.875    -.1286944     .151101
------------------------------------------------------------------------------

. estimates store A;

. generate chi2_rand = .;
(2123 missing values generated)

. generate df_rand = .;
(2123 missing values generated)

. generate p_rand = .;
(2123 missing values generated)

. generate dropcab = 0;

. generate seldrop = .;
(2123 missing values generated)

. local n = 1;

.   /* index for observations */
> 
> local i = 1;

. while `i'<101{;
  2.   qui replace seldrop = uniform();
  3.   qui replace dropcab = 1 if seldrop < 0.1;
  4.   qui clogit choice largestparty party_seatshare medianparty1 presidentparty previousPM president_investiture 
>         president_direct previousPM_conflict previousPM_gain1 previous_cabinet_gain1
>         largestparty_east party_seatshare_east medianparty1_east presidentparty_east previousPM_east 
>         previousPM_conflict_east previousPM_gain1_east previous_cabinet_gain1_east 
>         if dropcab!=1, group(cabinetcode);
  5.    estimates store B;
  6.   qui hausman B A, alleqs constant;
  7.   qui replace chi2_rand = r(chi2) if _n==`n';
  8.   qui replace df_rand = r(df) if _n==`n';
  9.   qui replace p_rand = r(p) if _n==`n';
 10.   qui replace dropcab = 0;
 11.   local i = `i' + 1;
 12.   local n = `n' + 1;
 13. };

.   *     ****************************************************************  *;
. *       Bonferroni corrections                                          *;
. *     ****************************************************************  *;
. egen ntest_rand = count(chi2_rand);

. generate U_p_rand = p_rand*0;
(2023 missing values generated)

. replace U_p_rand = 1 if p_rand<(0.05);
(24 real changes made)

. generate Bc_p_rand = p_rand*0;
(2023 missing values generated)

. replace Bc_p_rand = 1 if p_rand<(0.05/ntest_rand);
(14 real changes made)

. *     ****************************************************************  *;
. *       Display results                                                 *;
. *     ****************************************************************  *;
. ta Bc_p_rand;

  Bc_p_rand |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         86       86.00       86.00
          1 |         14       14.00      100.00
------------+-----------------------------------
      Total |        100      100.00

. ta U_p_rand;

   U_p_rand |      Freq.     Percent        Cum.
------------+-----------------------------------
          0 |         76       76.00       76.00
          1 |         24       24.00      100.00
------------+-----------------------------------
      Total |        100      100.00

. egen pmean = mean(p_rand);

. sum pmean;

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
       pmean |      2123    .5625309           0   .5625309   .5625309

. 
end of do-file

. log close
      name:  <unnamed>
       log:  C:\fsu2010\formateur\ajps\submission2\replication\analysis\IIAtest_rand.log
  log type:  text
 closed on:  11 Nov 2010, 15:24:57
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
